package com.itheima.tanhua.service;

import com.itheima.tanhua.api.db.UserServiceApi;
import com.itheima.tanhua.interceptor.userHolder;
import com.itheima.tanhua.pojo.db.user;
import com.itheima.tanhua.vo.HuanxinVo.HuanXinUserVo;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

/**
 * @author 芝士雪豹
 * @create 2022/9/28/16:49
 */
@Service
public class HuanXinService {
    @DubboReference
    private UserServiceApi userServiceApi;


    //查询环信用户和密码
    public HuanXinUserVo findHxUser() {
        //获取当前用户id
        Long userId = userHolder.getId();
        //调用api查询 mq查询
        user user = userServiceApi.findByUserId(userId);
        if (user == null) {
            return null;
        }
        //返回huanxin对象
        return new HuanXinUserVo(user.getHxUser(), user.getHxPassword());
    }
}
